/**
*  \file adc.c
*
*  \brief ADC sample function
*
*  \author dajin.li  <dajin.li@linde-china.cn>
*
*/

/*===============================================[ private includes  ]================================================*/
#include <xmc4500/adc_hw.h>
#include <xmc4500/io.h>
#include <xmc4500/processor.h>
#include <xmc4500/types_local.h>
#include "../sched/sched.h"
#include "../pal/pal_mem.h"



s16 AD_TempMotInv2;
s16 AD_TempMotInv1;


s16 AD_5VExtSns;    
s16 AD_13_7VSupply;                 

s16 AD_DcLink;                      
s16 AD_Accelerator1;    
s16 AD_Accelerator2;                    

s16 AD_SteerAngleB;  
s16 AD_SteerAngleA;                 

s16 AD_Reserve2; 
s16 AD_Reserve1;                    

s16 AD_CurrentCutOffIso;                    
s16 AD_CurrentMainCont;                 
s16 AD_KeySwitch; 

S16 AD_12VSupply;

s16 first_ads_done = 0;

/** Private variables */


void adc_tic(void)
{
    AD_5VExtSns          = adc_raw_5v_ext_sensor();
    AD_12VSupply         = adc_raw_12v_driver_supply();
    AD_13_7VSupply       = adc_raw_13_7_v_supply();

    AD_TempMotInv2       = adc_raw_temp_mot_inv2_in();
    AD_TempMotInv1       = adc_raw_temp_mot_inv1_in();

    AD_Accelerator1      = adc_raw_accelerator_1_in();
    AD_Accelerator2      = adc_raw_accelerator_2_in();
    
    AD_SteerAngleB       = adc_raw_steer_angle_b_in();
    AD_SteerAngleA       = adc_raw_steer_angle_a_in();

    AD_Reserve2          = adc_raw_reserve_2_in();
    AD_Reserve1          = adc_raw_reserve_1_in();

    AD_CurrentCutOffIso  = adc_raw_current_cut_off_iso_value();
    AD_CurrentMainCont   = adc_raw_current_main_contactor();
    
    AD_KeySwitch         = adc_raw_key_switch_in();
    AD_DcLink            = adc_raw_dc_link_in();
    
    first_ads_done = 1;
    
    return;
}






